﻿namespace Pangeo.Admin.Models.HrmDb.Dto
{
    public class TimeRange
    {
        public TimeRange()
        {

        }

        public TimeRange(DateTime start, DateTime end)
        {
            Start = start;
            End = end;
        }

        public DateTime Start { get; set; }

        public DateTime End { get; set; }

        public bool Overlaps(TimeRange other)
        {
            return Start < other.End && other.Start < End;
        }

        public TimeRange Merge(TimeRange other)
        {
            return new TimeRange(
                DateTime.Compare(Start, other.Start) < 0 ? Start : other.Start,
                DateTime.Compare(End, other.End) > 0 ? End : other.End
            );
        }
    }
}
